package cn.zktr.Personnel.model.uitls;

import java.util.ArrayList;
import java.util.List;

import cn.zktr.Personnel.model.pojos.PerPmsEmp;
import cn.zktr.Personnel.model.pojos.PerPmsFun;
import cn.zktr.Personnel.model.pojos.PerPmsFuns;
import cn.zktr.Personnel.model.pojos.PerPmsPes;
import cn.zktr.Personnel.model.pojos.PerPmsPot;
import cn.zktr.Personnel.model.pojos.PerPmsYG;
import cn.zktr.Personnel.model.pojos.PerPmsYQ;
//面向页面实体类
/**
 * @author lenovo
 *
 */
public class Homapape {
	//员工id
	private int empid;
	//员工姓名
	private String emp;
	//员工职位
	private String pot;
	//员工头像
	private String img;
	//员工部门id
	private int deptid;
	//员工部门
	private String dept;
	
	private List<Authority> aut;
	
	public Homapape(PerPmsEmp ppe) {
		setEmpid(ppe.getEmpid());
		setEmp(ppe.getEmpname());
		setPot(ppe.getPerPmsStms().get(0).getPerPmsPot().getPotzw());
		setDeptid(ppe.getPerPmsStms().get(0).getPerPmsDept().getDeptid());
		setDept(ppe.getPerPmsStms().get(0).getPerPmsDept().getDeptname());
		if(ppe.getPerPmsZts().size()!=0) {
			setImg(ppe.getPerPmsZts().get(0).getZthost());
		}
		setAut(ppe.getPerPmsYQs(),getEmpid());
	}
	public Homapape() {
		
	}
	
	public int getDeptid() {
		return deptid;
	}
	public void setDeptid(int deptid) {
		this.deptid = deptid;
	}
	public String getDept() {
		return dept;
	}
	public void setDept(String dept) {
		this.dept = dept;
	}
	public int getEmpid() {
		return empid;
	}
	public void setEmpid(int empid) {
		this.empid = empid;
	}
	public String getEmp() {
		return emp;
	}
	public void setEmp(String emp) {
		this.emp = emp;
	}
	public String getPot() {
		return pot;
	}
	public void setPot(String pot) {
		this.pot = pot;
	}
	public String getImg() {
		return img;
	}
	public void setImg(String img) {
		this.img = img;
	}
	public List<Authority> getAut() {
		return aut;
	}
	/**员工权限查询
	 * @param list
	 * @param i
	 */
	public void setAut(List<PerPmsYQ> list,int i) {
		List<Authority> aut_1 = new ArrayList<>();
		for(PerPmsYQ ppyq : list) {
			PerPmsPes ppp = ppyq.getPerPmsPe();
			List<Authority> aut_2 = new ArrayList<>();
			for(PerPmsFun ppf : ppp.getPerPmsFuns()) {
				List<Authority> aut_3 = new ArrayList<>();
				for(PerPmsFuns ppfs : ppf.getPerPmsFuns()) {
					if(ppfs.getFunsgad().equals("3")){
						aut_3.add(new Authority(ppfs));
					}
				}
				for(PerPmsYG ppyg : ppf.getPerPmsYGs()) {
					if(ppf.getFungad().equals("3")&&ppyg.getYgwht().equals("true")&&ppyg.getPerPmsEmp().getEmpid()==i){
						aut_2.add(new Authority(ppf, aut_3, i));
					}
				}
			}
			if(ppyq.getYqwht().equals("true")) {
				aut_1.add(new Authority(ppp, aut_2, i));
			}
		}
		this.aut = aut_1;
	}
	/**员工权限修改查询
	 * @param list
	 * @param ppe
	 */
	public void setAut(List<PerPmsYQ> list,PerPmsEmp ppe) {
		int i = ppe.getEmpid();
		List<Authority> aut_1 = new ArrayList<>();
		for(PerPmsYQ ppyq : list) {
			PerPmsPes ppp = ppyq.getPerPmsPe();
			List<Authority> aut_2 = new ArrayList<>();
			for(PerPmsFun ppf : ppp.getPerPmsFuns()) {
				List<Authority> aut_3 = new ArrayList<>();
				for(PerPmsFuns ppfs : ppf.getPerPmsFuns()) {
					aut_3.add(new Authority(ppfs));
				}
				aut_2.add(new Authority(ppf, aut_3, i));
			}
			aut_1.add(new Authority(ppp, aut_2, i));
		}
		this.aut = aut_1;
	}
	/**职位权限修改查询
	 * @param list
	 * @param ppe
	 */
	public void setAut(List<PerPmsPes> list,PerPmsPot pppo) {
		List<Authority> aut_1 = new ArrayList<>();
		for(PerPmsPes ppp : list) {
			List<Authority> aut_2 = new ArrayList<>();
			for(PerPmsFun ppf : ppp.getPerPmsFuns()) {
				List<Authority> aut_3 = new ArrayList<>();
				for(PerPmsFuns ppfs : ppf.getPerPmsFuns()) {
					aut_3.add(new Authority(ppfs));
				}
				aut_2.add(new Authority(ppf, aut_3, pppo));
			}
			aut_1.add(new Authority(ppp, aut_2, pppo));
		}
		this.aut = aut_1;
	}
	/**权限修改查询
	 * @param list
	 */
	public void setAut(List<PerPmsPes> list) {
		List<Authority> aut_1 = new ArrayList<>();
		for(PerPmsPes ppp : list) {
			List<Authority> aut_2 = new ArrayList<>();
			for(PerPmsFun ppf : ppp.getPerPmsFuns()) {
				List<Authority> aut_3 = new ArrayList<>();
				for(PerPmsFuns ppfs : ppf.getPerPmsFuns()) {
					aut_3.add(new Authority(ppfs));
				}
				aut_2.add(new Authority(ppf, aut_3));
			}
			aut_1.add(new Authority(ppp, aut_2));
		}
		this.aut = aut_1;
	}
}
